package com.example.core.utils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

public class ParamParser {

    public static Map<String, String> parseParam(String param) {
        Map<String, String> paramMap = new HashMap<>();

        String[] params = param.split("&");

        paramMap = Arrays.stream(params)
                .map(p -> p.split("="))
                .filter(p -> p.length == 2)
                .collect(Collectors.toMap(p -> p[0], p -> p[1]));

        return paramMap;
    }

}
